package Enemy;

import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;

public class SpaceBear{

    private int health;
    private int xPosition;
    private int yPosition;
    private int width;
    private int height;
    private int xSpeed;
    private int ySpeed;
    private int projXPos;
    private int projYPos;

    Image enemyBear;
    Image enemyBearDead;
    Image enemyBearHit;

    public SpaceBear(int x, int y){
        xSpeed = 1;
        ySpeed = 1;
        health = 10;
        xPosition = x;
        yPosition = y;
        projXPos = -100;
        projYPos = -100;
        width = 100;
        height = 139;
        enemyBear = new ImageIcon("images/enemyBear.gif") {}.getImage();
        enemyBearDead = new ImageIcon("images/enemyBearDead.gif") {}.getImage();
        enemyBearHit = new ImageIcon("images/enemyBearHit.gif") {}.getImage();
    }

    public int getProjX(){
        return projXPos;
    }

    public int getProjY(){
        return projYPos;
    }

    public int getHealth(){
        return health;
    }

    public void setHealth(int x){
        health = x;
    }

    public void changeHealth(int x){
        health = health - x;
        System.out.println(health);
    }

    public int getXPosition(){
        return xPosition;
    }

    public int getYPosition(){
        return yPosition;
    }

    public int getWidth(){
        return width;
    }

    public int getHeight(){
        return height;
    }

    public void drawEnemyBear(Graphics g){
        if(getHealth() <= 0){
            g.drawImage(enemyBearDead, getXPosition(), getYPosition(), null);
        }else{
            g.drawImage(enemyBear, getXPosition(), getYPosition(), getWidth(), getHeight(), null);
        }
    }

    public void bearMovement(){
        if(getHealth() > 0){
            xPosition = xPosition + xSpeed;
            yPosition = yPosition + ySpeed;
            if(xPosition <= 0){
                xSpeed = 1;
            }
            if(xPosition >= 600){
                xSpeed = -1;
            }
            if(yPosition <= 0){
                ySpeed = 1;
            }
            if(yPosition >= 800){
                ySpeed = -1;
            }
        }
    }

}
